<?php
/**
 * Created by PhpStorm
 * USER MingTingLiang   QQ 915802070
 * Date 2020-12-14-014   15:41
 */


require "IProduct.php";
require "ProductDataCenter.php";
require "ProdLoadTemplate.php";

class ProductFactory
{
    public static function getProduct($type)
    {
        if (is_array($type)) {
            foreach ($type as $item) {
                self::getObjectByType($item);
            }
        }

        if (is_string($type)) {
            self::getObjectByType($type);
        }
    }

    private static function getObjectByType( $type)
    {
        if (!class_exists($type)) {
            require $type . ".php";
            $obj = new $type();

            if (is_subclass_of($obj, "IProduct")) {
                ProductDataCenter::set($type, $obj);
            }
        }
    }

}